import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { quasar, transformAssetUrls } from '@quasar/vite-plugin'

import path from 'path'
const resolve = (dir) => path.join(__dirname, dir);

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue({
      template: { transformAssetUrls }
    }),
    vueJsx(),

    // @quasar/plugin-vite options list:
    // https://github.com/quasarframework/quasar/blob/dev/vite-plugin/index.d.ts
    quasar({
      sassVariables: 'src/css/quasar.variables.scss'
    })
  ],
  resolve: {
    alias: {
      // '@': fileURLToPath(new URL('./src', import.meta.url))
      '@': resolve('src'), // 设置别名
      'src': resolve('src'),
      'stores': resolve('src/stores'),
      'store': resolve('src/store'),
      'layouts': resolve('src/layouts'),
      'pages': resolve('src/pages'),
      'components': resolve('src/components'),
    }
  },
  server: {
    open: true, //自动打开浏览器
    port:5170,
    proxy: {
      "/api": {
        target: "https://yiguxianyun.gitee.io/amtf-sj", //目标网站,服务端地址
        changeOrigin: true,
        rewrite(path) {
          return path.replace(/^\/api/, "")
        },
      },
    },
  },
})